@extends(config('admin.systems.layout_blade'))

@section('content')
    <button type="button" onClick="upImage()">调用上传图片模块</button>
    <br>
    <button type="button" onClick="upFiles()">调用上传文件模块</button>

    <textarea name="content" type="text/plain">{{ uploads_path() }}</textarea>


@endsection

@section('script')

    <script type="text/javascript" id="j_ueditorupload"></script>
    <script type="text/javascript" charset="utf-8" src="{{ asset('plugins/ueditor/1.4.3/ueditor.config.js') }}"></script>

    <!--使用版-->

    <script type="text/javascript" charset="utf-8" src="{{ asset('plugins/ueditor/1.4.3/ueditor.all.js') }}"></script>

    <script type="text/javascript" src="{{ asset('plugins/ueditor/1.4.3/lang/zh-cn/zh-cn.js') }}"></script>

    <script>
        $('textarea[name="content"]').attr('id', 'editor_id_1');
        window.UEDITOR_HOME_URL = "{{ asset('plugins/ueditor/1.4.3') }}";
        window.UEDITOR_CONFIG.zIndex = 1000;
        window.UEDITOR_CONFIG.charset = "utf-8";
        window.UEDITOR_CONFIG.initialFrameWidth = parseInt(600);
        window.UEDITOR_CONFIG.initialFrameHeight = parseInt(500);
        window.UEDITOR_CONFIG.scaleEnabled = false;
        window.UEDITOR_CONFIG.fontsize = [10, 11, 12, 14, 16, 18, 20, 24, 36, 48, 56];
//        window.UEDITOR_CONFIG.serverUrl = ''; //  公共的上传地址 后期自定义时候可以修改
        var ue = UE.getEditor('editor_id_1');
//        var configUrl = ue.getActionUrl('config');
//        alert(configUrl);


        //实例化编辑器
        var o_ueditorupload = UE.getEditor('j_ueditorupload',
            {
                autoHeightEnabled:false
            });
        o_ueditorupload.ready(function ()
        {

            o_ueditorupload.hide();//隐藏编辑器

            //监听图片上传
            o_ueditorupload.addListener('beforeInsertImage', function (t,arg)
            {
                alert('这是图片地址：'+arg[0].src);
            });

            /* 文件上传监听
             * 需要在ueditor.all.min.js文件中找到
             * d.execCommand("insertHtml",l)
             * 之后插入d.fireEvent('afterUpfile',b)
             */
            o_ueditorupload.addListener('afterUpfile', function (t, arg)
            {
                alert('这是文件地址：'+arg[0].url);
            });
        });



        //弹出图片上传的对话框
        function upImage()
        {
            var myImage = o_ueditorupload.getDialog("insertimage");
            myImage.open();
        }

        //弹出文件上传的对话框
        function upFiles()
        {
            var myFiles = o_ueditorupload.getDialog("attachment");
            myFiles.open();
        }

    </script>
@endsection